#ifndef __COMM_DATAPACK_H
#define __COMM_DATAPACK_H

#include "stdint.h"
#include <stdlib.h>

#ifdef __cplusplus
 extern "C" {
#endif

#define ID_MR813			    0x20
#define ID_DEBUG		        0x22
#define ID_AT                   0x23
#define ID_SELF			        0x24 // ECU
#define ID_TCU			        0x25 
// #define ID_BSU			        0x26 
#define ID_CGS			        0x21 //Keep pace with Raptor

#ifndef WL_PROJECT_COOPER
#define ID_VCU1	                0x30 // VCU GD32
#define ID_VCU2	                0x31
#define ID_VCU3	                0x32
#define ID_VCU4	                0x33
#else
#define ID_VCU1                 0x30
#define ID_VCU2                 0x31
#endif

#define ID_PDA                  0x3B
#define ID_SMART_HOST           0x3D

#define DATA_HEAD0	0x5A
#define DATA_HEAD1	0xA5
#define DATA_LEN	255

/*  CMD in protocol of EE  */
#define COMM_CMD_CMAP_RD                        0x01 //read
#define COMM_CMD_CAMP_WR                        0x02 //write with response
#define COMM_CMD_CAMP_WR_NR                     0x03 //write without response
#define COMM_CMD_ACK_RD                         0x04 //ack of read
#define COMM_CMD_ACK_WR                         0x05 //ack of write

/*  CMD in IAP  */
#define COMM_CMD_IAP_BEGIN                      0x07 //iap begin
#define COMM_CMD_IAP_TRANS                      0x08 //transform data
#define COMM_CMD_IAP_VERIFY                     0x09 //verify data
#define COMM_CMD_IAP_RESET                      0x0A //reset, for upgrade from AP
#define COMM_CMD_IAP_ACK                        0x0B //ack
#define COMM_CMD_IAP_RESET_NOW                  0x0C //ack ECU, for upgrade from NPI

/*  CMD of host  */
#define COMM_CMD_HOST_WRITE_PN                  0x19

/*  CMD of test  */
#define COMM_CMD_AP_TEST_MODE                   0x20

/*  result of IAP  */
#define COMM_IAP_OK                             0x00 //write success
#define COMM_IAPERROR_SIZE                      0x01 //size is too large
#define COMM_IAPERROR_ERASE                     0x02 //erase error
#define COMM_IAPERROR_WRITEFLASH                0x03 //write flash error
#define COMM_IAPERROR_UNLOCK                    0x04 //status error
#define COMM_IAPERROR_INDEX                     0x05 //index error
#define COMM_IAPERROR_BUSY                      0x06 //busy
#define COMM_IAPERROR_FORM                      0x07 //form error
#define COMM_IAPERROR_CRC                       0x08 //crc error
#define COMM_IAPERROR_RESET                     0x09 //reset error
#define COMM_IAPERROR_PARAM                     0x10 //parameter error
#define COMM_IAPERROR_STATUS                    0x11 //robot status error

int32_t packData2Ap(uint8_t *pu8Data, uint8_t u8DataSize, uint8_t u8Index, uint8_t u8Cmd, uint8_t u8SrcId, uint8_t u8DstId);

#ifdef __cplusplus
}
#endif
#endif
